<?php
namespace App\Services\IntegralGoods;

use App\Services\ProjectValidate;
/**
 * 商品分类模块验证规则集合
 *
 * Class ValidateGoods
 */
class ValidateGoodsCategory extends ProjectValidate
{
    /**
     * 自定义子类初始化
     * @param array $initData
     * @return mixed
     */
    public function initValidate($initData = [])
    {
        if(!empty($initData['action'])) {
            $initData['action'] == 'edit' && $this->rules = ['id' => 'required|integer|min:1', 'app_id' => 'required|integer|min:1'];
            $initData['action'] == 'delCate' && $this->rules = ['id' => 'required|array|min:1', 'app_id'];
            $initData['action'] == 'goodsCateList' && $this->rules = ['id'=>'required|integer','app_id','recommend'];
            $initData['action'] == 'oneCateInfo' && $this->rules = ['id'=>'required|integer|min:1','app_id'];
            $initData['action'] == 'changeCateStatus' && $this->rules = ['status'=>'required|in:0,1','id'=>'required|array|min:1','app_id'];
        }
    }

    public $rules = [
        'app_id'               =>     'integer|min:1',
        'is_public'            =>     'in:0,1',
        'name'                 =>     'between:2,25',
        'id'                   =>     'integer|min:1',
        'limit'                =>     'integer|min:0',
        'pid'                  =>     'integer|min:0',
        'order'                =>     'integer|min:0',
        'status'               =>     'in:0,1',
    ];

    public $messages = [
       
    ];

    /**
     * @var array 上面规则中定义的 key 的名字
     */
    public $attributes = [
      
    ];
}